{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['a', 'b']\n",
      "args\n",
      "kwargs\n",
      "(10,)\n",
      "['c']\n",
      "{'c': 20}\n",
      "{}\n"
     ]
    }
   ],
   "source": [
    "import inspect\n",
    "\n",
    "def my_func(a, b=10, *args, c=20, **kwargs):\n",
    "    pass\n",
    "\n",
    "\n",
    "argspec = inspect.getfullargspec(my_func)\n",
    "print(argspec.args)           # ['a', 'b']\n",
    "print(argspec.varargs)        # 'args'\n",
    "print(argspec.varkw)          # 'kwargs'\n",
    "print(argspec.defaults)       # (10,)\n",
    "print(argspec.kwonlyargs)     # ['c']\n",
    "print(argspec.kwonlydefaults) # {'c': 20}\n",
    "print(argspec.annotations)    # {}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "sys.version_info(major=3, minor=7, micro=16, releaselevel='final', serial=0)"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sys\n",
    "type(sys.version_info)\n",
    "sys.version_info\n",
    "#打印python版本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pickle\n",
    "\n",
    "class Serializable:\n",
    "    def __init__(self, data):\n",
    "        self.data = data\n",
    "    \n",
    "    def __getstate__(self):\n",
    "        return self.data\n",
    "    \n",
    "    def __setstate__(self, state):\n",
    "        self.data = state"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "b'\\x80\\x03c__main__\\nSerializable\\nq\\x00)\\x81q\\x01X\\x0b\\x00\\x00\\x00Hello Worldq\\x02b.'"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "obj = Serializable(\"Hello World\")\n",
    "serialized_data = pickle.dumps(obj)\n",
    "serialized_data\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "deserialized_obj = pickle.loads(serialized_data)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Hello World\n"
     ]
    }
   ],
   "source": [
    "print(deserialized_obj.data)\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "orig_nbformat": 4
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
